﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TheLoader
{
    public partial class frmConfigure : Form
    {
        private int _NumberOfUsers = 1;
        private int _NumberOfRuns = 1;
        private int _UserPause = 0;

        public int NumberOfUsers
        {
            get { return _NumberOfUsers; }
            set { _NumberOfUsers = value; }

        }

        public int NumberOfRuns
        {
            get { return _NumberOfRuns; }
            set { _NumberOfRuns = value; }

        }

        public int UserPause
        {
            get { return _UserPause; }
            set { _UserPause = value; }

        }

        public Form1 myParent { get; set; }
        public frmConfigure()
        {
            InitializeComponent();
        }

        private void frmConfigure_Load(object sender, EventArgs e)
        {
            textBox1.Text = NumberOfUsers.ToString();
            textBox2.Text = NumberOfRuns.ToString();
            textBox3.Text = UserPause.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bool passed = false;
            passed = int.TryParse(textBox1.Text, out _NumberOfUsers);
            passed = int.TryParse(textBox2.Text, out _NumberOfRuns);
            passed = int.TryParse(textBox3.Text, out _UserPause);

            if (passed)
            {
                myParent.NumberOfUsers = this.NumberOfUsers;
                myParent.NumberOfRuns = this.NumberOfRuns;
                myParent.UserPause = this.UserPause;
                this.Close();
            }
            else
            {
                MessageBox.Show("One of your parameters in not an integer. Please check your settings and try again.", "Error", MessageBoxButtons.OK);
            }
        }
    }
}
